#ifndef _CIRCULAR_DEQUE_H_
#define _CIRCULAR_DEQUE_H_

#include<iostream>
#include<thread>
#include<deque>
#include<mutex>
#include<condition_variable>
#include<stdio.h>
using namespace std;
template<typename T>
class circularDeque
{
private:
//typedef shared_ptr<mutex>  recoMutex;
//typedef shared_ptr<condition_variable> recoCond;
	deque<T>                    _content;
	int                        _iMaxSize;
public:
	circularDeque(int maxSize)
		//:_mtx2(new mutex()),
		//_notEmptyCond( new condition_variable()),
		//_notFullCond(new condition_variable())
	{
		_iMaxSize = maxSize;
		//printf("Buffer initialized %p\n",_mtx2);
	}

	~circularDeque()
	{
	}
	int size()
	{
		return _content.size();
	}
	deque<T>& getDeque()
	{
		return _content;
	}
	//Thread unsafe interface,just used in one process
	void addItem(const T& item)
	{
		while(_content.size() >= _iMaxSize)	
		{
			 _content.pop_front();
		}
		_content.push_back(item);	
	}
};
#endif
